package com.example.webchar.webchar.mapper.slave;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.webchar.webchar.pojo.Novel;
import com.example.webchar.webchar.pojo.Users;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;


/**
 * @program: webchars
 * @description
 * @author: YouName
 * @create: 2021-06-24 14:11
 **/
@Mapper
@Service
public interface UserMapperSlave extends BaseMapper<Users> {
    /**
     * 登录
     *
     * @param username 账号
     * @param password 密码
     * @return
     */
    @Select("select * from users where name=#{username}and password=#{password}")
    Users loginUser(@Param("username") String username, @Param("password") String password);

    /**
     * 根据user获取rose表中的关系
     *
     * @param userId
     * @return
     */
    @Select("select rose_id from rose_users where user_id=#{userId}")
    Integer queryRoseId(@Param("userId") Integer userId);


    /**
     * 获取当前user的角色
     *
     * @param roseId
     * @return
     */
    @Select("select rose_name from rose where id=#{roseId}")
    String queryRoseName(@Param("roseId") Integer roseId);

    /**
     * 查询所有的users表中的name信息
     *
     * @return
     */
    @Select("select name from  users")
    List<Users> queryUsers();

}
